package util
{
	import mx.formatters.DateFormatter;
	
	public class DateUtils
	{
		
		private static var xqArr:Array = ["日","一","二","三","四","五","六"];
		
		public function DateUtils()
		{
		}
		
		public static function getYMDString(date:Date):String{
			var dateFormater:DateFormatter = new DateFormatter();
			dateFormater.formatString = "YYYYMMDD";
			return dateFormater.format(date);
		}
		
		public static function getFormatterDate(date:Date):String{
			var dateFormater:DateFormatter = new DateFormatter();
			dateFormater.formatString = "YYYY-MM-DD";
			return dateFormater.format(date);
		}
		
		public static function getFormatterDateYMDHSM(date:Date):String{
			var dateFormater:DateFormatter = new DateFormatter();
			dateFormater.formatString = "YYYY-MM-DD HH:NN:SS";
			return dateFormater.format(date);
		}
		
		public static function getChineseDate(date:Date):String{
			var dateFormater:DateFormatter = new DateFormatter();
			dateFormater.formatString = "YYYY年MM月DD日 星期";
			var E:Number = date.day;
			return dateFormater.format(date) + xqArr[E];
		}
		
		public static function getCurrWeek(d:Date):Array {
			var fm:DateFormatter = new DateFormatter();
			fm.formatString = "YYYY-MM-DD";
			var today:Number = (d.day == 0 ? 7 : d.day);
			var d1:Date = new Date(d.fullYear,d.month,d.date);
			d1.date = d1.date - (today - 1);
			var d2:Date = new Date(d.fullYear,d.month,d.date);
			d2.date = d2.date + (7 - today);
			var days:Array = new Array();
			days.push(fm.format(d1));
			days.push(fm.format(d2));
			return days;
		}
		
	}
}